<html>

	<head>
		<title>DeviceOrientationEvent</title>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<script src="util/jibu.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			.www {
				width: 100px;
				height: 50px;
				text-align: center;
				line-height: 50px;
				font-size: 18px;
				background: green;
				color: #fff;
				margin: 100px auto;
			}
		</style>
	</head>

	<body>

		<div id="jiasudu">

		</div>
	</body>

</html>

<script>
	var Ldirection = ''; //浏览器方向
	var resultX = 1; //xy坐标
	var resultY = 1; //xy坐标
	var AccelerometerX, AccelerometerY, AccelerometerZ; //加速计三个方向的数据
	var count = 0;
	var responseObj = {};
	var wobushu;

	//	function jianting() {
	if(window.DeviceMotionEvent) {
		window.addEventListener('devicemotion', deviceMotionHandler, false);

		setInterval(function() {
			
//			wobushu = PDRNavigation(0.1, 0.1, 9.8, Ldirection, 29, 12);
			wobushu = PDRNavigation(AccelerometerX, AccelerometerY, AccelerometerZ, Ldirection, resultX, resultY);
			console.log('wobushu', wobushu)
			//					var newCoord = {
			//						'x': responseObj.X,
			//						'y': responseObj.Y
			//					}
			//					resultX = responseObj.X;
			//					resultY = responseObj.Y;
			resultX = count;
			resultY = count;
			count++;
			//					var mapCoord = CoordTransform(newCoord);
			//					setLocationMakerPosition(mapCoord, null, Ldirection);
		}, 1000)

	}
	var vibrateSupport = "vibrate" in navigator
	if(vibrateSupport) { //兼容不同的浏览器
		navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
	}
	//	}

	function deviceMotionHandler(eventData) {
		var acceleration = eventData.accelerationIncludingGravity;
		AccelerometerX = acceleration.x;
		AccelerometerY = acceleration.y;
		AccelerometerZ = acceleration.z;

		var jtext = ''
		var jiasudu = document.getElementById("jiasudu");
		jtext += "x方向：" + AccelerometerX + "<p>";
		jtext += "y方向：" + AccelerometerY + "<p>";
		jtext += "z方向：" + AccelerometerZ + "<p>";
		jtext += "resultX：" + resultX + "<p>";
		jtext += "resultY：" + resultY + "<p>";

		jtext += "wobushu：" + wobushu + "<p>";
		

		jiasudu.innerHTML = jtext;
	}
</script>